/*
*         (C) COPYRIGHT NBI Limited
*              ALL RIGHT RESERVED
*
* File        : fastflow/graph/function_impl.h
* Authors     : dzhang
* Create Time : 2021/09/06 16:08:43
* Description :
*
*/

#ifndef __FASTFLOW_GRAPH_FUNCTION_IMPL_H___
#define __FASTFLOW_GRAPH_FUNCTION_IMPL_H___

#include "fastflow/graph/function.h"

namespace fastflow {
class Graph;
class Node;
class Model;
}  // namespace fastflow

namespace fastflow {

// Function representation class.
class FunctionImpl final : public Function {
 public:
  FunctionImpl(const fastflow::Graph& graph,
               std::unique_ptr<IndexedSubGraph> customized_func);

  FunctionImpl(const fastflow::Graph& graph,
               const fastflow::NodeIndex& node_index,
               const ONNX_NAMESPACE::FunctionProto* onnx_func);
  
  ~FunctionImpl();
  
  const ONNX_NAMESPACE::OpSchema& OpSchema() const override;

  const fastflow::Graph& Body() const override;

  const IndexedSubGraph& GetIndexedSubGraph() const override;

  const ONNX_NAMESPACE::FunctionProto* GetFuncProto() const;

 private:
  const fastflow::Graph* const parent_graph_;
  std::unique_ptr<IndexedSubGraph> customized_func_body_;
  std::unique_ptr<ONNX_NAMESPACE::OpSchema> op_schema_;
  std::unique_ptr<fastflow::Model> body_;
  const ONNX_NAMESPACE::FunctionProto* onnx_func_proto_;
};

}  // namespace fastflow

#endif // __FASTFLOW_GRAPH_FUNCTION_IMPL_H___
